<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{margin: 0;padding: 0;}
        div{width: 300px;
            margin: 30px auto;}
        p{padding-left: 50px;}    
    </style>
</head>
<body>
    <div>
        <p>
            <span id="sec">5</span>秒后跳转
        </p>
        <a href="https://www.baidu.com/">如果没有跳转,请点击此处</a>
    </div>

    <script>
        var sec = document.getElementById("sec");
        setInterval(function(){
           var time = sec.innerText;
           if(time > 0){
            time--;
            sec.innerText = time;
           }else{
            location.href = "https://www.baidu.com/";
           }
        },1000)
    </script>
</body>
</html>